
<template>
  <el-form-item :label="i18nt('designer.setting.actionButtonEditing')">
    <el-button type="primary"
      round
      plain
      @click="onDataSourceEdit">编辑</el-button>
  </el-form-item>
  <operation-button-edit-dialog ref="operationButtonEditDialogRef"></operation-button-edit-dialog>
</template>

<script>
import i18n from "@/utils/i18n"
import propertyMixin from "@/components/form-designer/setting-panel/property-editor/propertyMixin"
import { OperationButtonEditDialog } from '@/components/dialogs'
import eventBus from '@/utils/event-bus';

export default {
  name: "action-button-editor",
  mixins: [i18n, propertyMixin],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },
  components: { OperationButtonEditDialog },
  mounted() {
    //用于兄弟组件接收事件
    eventBus.$on('buttonGroupData', data => {
      this.optionModel.fieldOptions = [
        ...data
      ]
    });
  },
  methods: {
    onDataSourceEdit() {
      const array = this.optionModel.fieldOptions ?? []
      this.$refs.operationButtonEditDialogRef.handleOpen(array)
    }
  },
}
</script>

<style lang="scss" scoped>
</style>
